<template>
  <div>

    <el-row class="app-toptool" type="flex">
      <el-col :span="18">
        <Search
          size="mini"
          :search-visible="searchVisible"
          :search-data.sync="searchData"
          :search-form="searchForm"
          @refesh_list="searchgo"
        />
      </el-col>
      <el-col :span="6">
        <div class="btn-group" style="margin-bottom:11px;float: right;">
          <div>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-alert title="小程序订单中心path:" type="info" show-icon>
      <div>
        pagesA/my/myOrder/myOrder
      </div>
    </el-alert>
    <div id="charts_one" style="width:100%;min-height:80vh">
      <el-table
        ref="multipleTable"
        v-loading="loading"
        :row-class-name="rowClass"
        row-key="id"
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
        :border="false"
        :stripe="true"
        class="eltable"
        :data="list"
        style="width: 100%"
        @selection-change="selection"
      >
        <el-table-column align="center" type="selection" width="42" />
        <el-table-column
          align="center"
          type=""
          property="id"
          label="编号"
          show-overflow-tooltip
          width="70"
        />
        <el-table-column
          align="center"
          property="title"
          label="名称"
          show-overflow-tooltip
          width="200"
        />
        <el-table-column
          align="left"
          property="url"
          label="页面"
          show-overflow-tooltip
          width=""
        />
      </el-table>
    </div>
  </div>
</template>
<script>
import Search from '@/components/common/Search.vue'
export default {
  name: 'miniprogrampage',
  components: {
    Search
  },
  data() {
    return {
      ids: [],
      single: true,
      multiple: true,
      list: [],
      exceldata: [],
      dumppage: 1,
      ws: {},
      dumpshow: false,
      percentage: 0,
      filename: '',
      loading: false,
      searchVisible: true,
      searchForm: [],
      searchData: {}
    }
  },
  mounted() {
    this.index()
  },
  methods: {
    searchgo() {
      this.index()
    },
    index() {
      let param = {}
      if (this.searchData) param = Object.assign(param, this.searchData)
      this.loading = true
      this.$api.post('/Miniprogrampage/index', param).then(res => {
        this.list = res.data
        this.loading = false
        this.searchForm = [{
          type: 'Input',
          label: '关键词',
          prop: 'keyword',
          width: '200px'
        }]
      })
    },
    selection(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    handleRowClick(row, rowIndex, event) {
      if (event.target.className !== 'el-input__inner') {
        this.$refs.multipleTable.toggleRowSelection(row)
      }
    },
    rowClass({
      row,
      rowIndex
    }) {
      for (let i = 0; i < this.ids.length; i++) {
        if (row.id === this.ids[i]) {
          return 'rowLight'
        }
      }
    }
  }
}
</script>
